Bentley Map V8i (SELECTseries 10) Help

Basic Functions

The following functions can be used in expressions.

All trigonometric functions use degrees for measurement of angles.

Function

Description

SIN (x)

Trigonometrical sinus function.

COS (x)

Trigonometrical cosines function.

TAN (x)

Trigonometrical tangent function.

ARCSIN (x)

Inverse sinus.

ARCCOS (x)

Inverse cosines.

ARCTAN (x)

Inverse tangent.

ROUND (x)

Rounds off a floating point number to the closest integer.

Example: a = round(5.67) results in the number 6.

TRUNC (x)

Truncates (rounds down) a floating point number resulting in an integer.

Example: a = trunc(5.67) results in the number 5.

ABS (x)

Returns the absolute (positive) value.

Example: a = abs(-5.67) results in the number 5.67.

SQRT (x)

Square root.

Example: a = sqrt(4.5) results in the number 2.1213203.

SQR (x)

Square.

Example: a = sqr(2) results in the number 4.

LN (x)

Natural logarithm.

Example: a = ln(4.3) results in the number 1.458615.

LOG (x)

Base ten logarithm.

Example: a = log(4.3) results in the number 0.6334685.

EXP (x)

Exponential.

Example: a = exp(3.2) results in the number 24.53253.

MIN2 (v1, v2)

Minimum of two values.

Example: a = min2(37, 98) results in the number 37. v1 and v1 can be both number and strings, as long as they have the same data type.

MAX2 (v1, v2)

Maximum of two values.

Example: a = max2(37, 98) results in the number 98. v1 and v1 can be both number and strings, as long as they have the same data type.

TONUM (s)

Converts a string to a number.

Example: d = tonum(“45.32”) results in the number 45.32.

TOSTR (n,i1,i2)

Converts a number to a text string. The parameter “n” is the number (floating point or integer). i1 is the minimum text string width. i2 is the number of decimals to be used.

Example: s = tostr(sin(50), 6, 4) results in the text “0.7660.”

UPPERCASE (s)

Converts all letters in the text string to uppercase.

Example: s = uppercase(“hello world”) results in “HELLO WORLD.”

LOWERCASE (s)

Converts all letters in the text string to lowercase.

Example: s = lowercase(“HELLO WORLD”) results in “hello world.”

TRIM (s)

Removes trailing blanks from a text string.

Example: s = trim(“hello ”) results in “hello.”

LTRIM (s)

Removes leading and trailing blanks from a text string.

Example: s = ltrim(“ hello ”) results in “hello.”

RTRIM (s,n)

Right justifies text making sure it is set to a width of n characters.

Example: s = rtrim(“hello”, 10) results in “hello.”

FIX (s,n)

Sets the width of a string to a fixed value by either truncating or filling with trailing blanks.

Example: s = fix(“hello”, 2) results in “he.” s = fix(“hello”, 10) results in “hello ”

INDEX (s1,s2)

Returns the index in the string s1 where the substring s2 is first found.

Example: i = index(“hello world”, “wor”) results in 7. If the substring is not found, the result is zero.

SUBSTR (s,i,n)

Returns a substring from the string s. The substring starts at character i and is n characters long.

Example: s = substr(“hello world”, 7,5) results in “world.”

STRLEN (s)

Returns the length of a string, that is, the number of characters.

Example: n = strlen(“hello world”) results in 11.

PAD (s,c,n)

Fills the text string s with the character c making the total length of the text string n characters long.

Example: t = pad(“hello”, “!”, 10) results in “hello!!!!!”

MIN(aaa)

Minimum value in the array aaa.

Example:

aaa[1] = 37
aaa[2] = 98
aaa[3] = 57
a = min(aaa), results in a equals 37

MAX(aaa)

Maximum value in the array aaa.

Example:

aaa[1] = 37
aaa[2] = 98
aaa[3] = 57
a = max(aaa), results in a equals 98

COUNT(aaa)

Number of elements in then array aaa.

Example:

aaa[1] = 37
aaa[2] = 98
aaa[3] = 57
a = count(aaa), results in a equals 3

SORT(aaa, descending)

Results in a new array with sorted elements (ascending or descending).

Example:

aaa[1] = 37
aaa[2] = 98
aaa[3] = 57
bbb = sort(aaa, FALSE),  results in
bbb[1] equals 37
bbb[2] equals 57
bbb[3] equals 98
bbb = sort(aaa, TRUE),  results in
bbb[1] equals 98
bbb[2] equals 57
bbb[3] equals 37 

SORTIDX(aaa, descending)

Results in a new array containing sorted index numbers.

Example:

aaa[1] = 37
aaa[2] = 98 
aaa[3] = 57
bbb = sortidx(aaa, FALSE), results in
bbb[1] equals 1
bbb[2] equals 3
bbb[3] equals 2
bbb = sortidx(aaa, TRUE), results in
bbb[1] equals 2
bbb[2] equals 3
bbb[3] equals 1

FIRSTIDX(aaa)

The first (smallest) used index in the array aaa.

Example:

aaa[12] = 37
aaa[10] = 98
aaa[18] = 57
a = firstidx(aaa), results in a equals 10

LASTIDX(aaa)

The last (greatest) used index in the array aaa.

Example:

aaa[12] = 37
aaa[10] = 98
aaa[18] = 57
a = firstidx(aaa), results in a equals 18

NEXTIDX(aaa, x)

The next used index in the array aaa after (greater than) the value x.

Example:

aaa[20] = 37
aaa[25] = 98
aaa[52] = 57
a = nextidx(aaa, 20), results in a equals 25
a = nextidx(aaa, 35), results in a equals 52
a = nextidx(aaa, 75), results in a equals 53

Example: Running through the elements of an array with holes can be done like this:

for (i=firstidx(aaa); i<=lastidx(aaa); i=nextidx(aaa,
i))
... 
end 

PREVIDX(aaa, x)

The previously used index in aaa before (less than) x.

Example:

aaa[20] = 37
aaa[25] = 98
aaa[52] = 57
a = previdx(aaa, 22), results in a equals 20
a = previdx(aaa, 35), results in a equals 25
a = previdx(aaa, 75), results in a equals 52
a = previdx(aaa, 20), results in a equals 19 

The following functions are used to manipulate date and time values.

Function

Description

TIME()

Time as a number. Time 1200 is 0.5. Time 1800 is 0.75

Example: t = time() + 1/24, results in t equals 0.5625, if the time is 1230.

There are no parameters to the time() function.

TIMETOSTRING(t, s)

Returns time as text, given the time value as a number and a format string.

Example: s = timetostring(0.5, "hh:mm:ss") result in s equals “12:00:00.”

STRINGTOTIME()

Returns time as a number, given a time string and a format string.

Example: t = stringtodate("14:45:05", "hh:mm:ss") results in t equals 0.61464120

DATE()

Returns the date as an (signed) integer corresponding to the number of days since Jan. 1. 1900.

Example: d = date() result in d equals 36445, if the date is 10-oct-1999.

There are no parameters to the date() function.

DATETOSTRING()

Returns a date string given the date as an integer number and a format string.

Example: s = datetostring(30001, “dd-mm-yyyy”) results in s equals “21-02-1982.”

STRINGTODATE()

Returns the date as an integer number, given the date as a date string and a format string.

Example: d = stringtodate(“24/12/1979,” “dd/mm/yyyy”) results in d equals 29211.

DEFINED(name)

Returns TRUE if a variable with the specified name exist, otherwise the function returns FALSE.

Example: b = defined(sum), results in b equals TRUE if a variable named sum exist. The function can also be used in indexed variables.

Example: b = defined(abc[3]), results in b equals TRUE if the array abc exits and contains an element with index 3.